# encoding=utf-8
from seg_system.LongTaskStatusUpload import MultiStatusUploadImpl
from seg_common.MiddleWareService import RedisService


class LongTaskMonitorService:
    """RedisService的二次封装类,只要用于每次接口访问的时候获取任务的进行状态
    """

    def __init__(self):
        self.monitor = MultiStatusUploadImpl()
        self.struct = self.monitor.get_info_struct()
        self.redis = RedisService()

    def update_monitor(self):
        """后面会用来更新self.monitor，从而进行动态切换"""
        pass

    def get_info(self, info: str, redis_key: str, **kwargs):
        if info in self.struct:
            redis_dict = self.redis.key_get(redis_key)
            return redis_dict[info]
        else:
            return "Not Found"

    def get_all(self, redis_key: str, **kwargs):
        return self.redis.key_get(redis_key)
